<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >  

    <!--    <h:body>-->
    <ui:composition template="layout.xhtml">
        <ui:define name="corpo">
            <h:form id="index_form" acceptcharset="utf-8"> 
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('config.xhtml')}" value="Configurações" update="@form" immediate="true"/> >
                    <p:commandLink  value="Ato" update="@form" immediate="true"/>
                </div>
                <p:panel header="Principal - Ato">
                    <h:panelGrid style="float: right;" columns="6">
                        <p:graphicImage url="/media/img/new.png" title="Cadastrar Ato" />
                        <p:commandLink   value="Cadastrar" title="Cadastrar Ato" 
                                         actionListener="#{managerAto.redirect('criarAto.xhtml')}" 
                                         update="@form"/>
                        <p:graphicImage url="/media/img/search.png" title="Pesquisar Ato"/><p:commandLink value="Pesquisar" title="Pesquisar Ato" actionListener="#{managerConsultarAtoItem.redirect('buscarAto.xhtml')}" update="@form"/>
                        
                      <p:graphicImage url="/media/img/avancado.png" title="Avançado" /><p:commandLink value="Avançado" id="linkAvance" style="margin-left: -7px;"  title="Avançados" />
                        <p:overlayPanel id="certidoes" for="linkAvance"
                                        hideEffect="fade" style="width:100px;">  
                            <h:panelGrid columnClasses="paddingColuna" columns="2">
                                <p:graphicImage url="/media/img/verme.png" title="Cancelar Selo" />
                                <p:commandLink value="Sincronizar" title="Cancelar Selo" 
                                               action="#{managerImovel.redirect('emolumentotj.xhtml')}" />
                                
                                <p:graphicImage url="/media/img/new.png" title="Cadastrar Tipo do Ato" /> 
                                <p:commandLink   value="Tipo do Ato" title="Cadastrar Ato Tipo" 
                                              actionListener="#{managerIndex.redirect('criarAtoTipo.xhtml')}" update="@form"/>
                                
                                <p:graphicImage url="/media/img/new.png" title="Cadastrar Ato Campo" /> 
                                <p:commandLink  value="Ato Campo" title="Cadastrar Ato Campo" 
                                              actionListener="#{managerIndex.redirect('indexAtoCampo.xhtml')}" update="@form"/>
                            </h:panelGrid>
                        </p:overlayPanel> 
                      
                    </h:panelGrid>
                    
                    <br/>
                     <p:blockUI block="atoTable" trigger="atoTable">  
                        CARREGANDO...<br />  
                        <p:graphicImage value="/media/img/ajax-loader.gif"/>  
                    </p:blockUI>
                    <p:dataTable id="atoTable" var="ato" value="#{managerVisualizarAtoItem.atoItens}" 
                                 paginator="true" rows="20"
                                 paginatorPosition="bottom"
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                 rowsPerPageTemplate="5,10,15">    

                        <f:facet name="header">  
                            Todos Atos Cadastrados 
                        </f:facet>
                        <p:column style="width:4%">  
                                    <p:rowToggler  />  
                        </p:column>  
                        <p:column  style="width:40px;">  
                            <f:facet name="header" >   
                                Codigo
                            </f:facet>  
                            <h:outputText value="#{ato.codigo}" style=" float:right;"  />  
                        </p:column>

                        <p:column headerText="Descrição"> 
                            <h:outputText value="#{ato.descricao}"   />  
                        </p:column>
                        <p:column headerText="Selo" style="width:175px;">  
                            <h:outputText value="#{ato.tipoSelo.nome}"  />  
                        </p:column>
                        <p:column  headerText="Cor" style="width:40px;">  
                            <table>
                                <tr>
                                    <td class="borderZero" 
                                        style="height:25px; width: 10px; background-color: \##{ato.tipoSelo.corSelo.cor};"></td>
                                </tr>
                            </table>
                        </p:column>
                        <p:column headerText="Opções" style="width:55px;">  
                            <p:commandButton  icon="editar" style="width:25px; height:25px;" 
                                              actionListener="#{managerEditarAtoItem.redirect('editarAto.xhtml', ato)}" 
                                              update="@form"/> 
                            <p:commandButton  icon="view" style="width:25px; height:25px;" 
                                              actionListener="#{managerVisualizarAtoItem.redirect('visualizarAto.xhtml', ato)}" 
                                              update="@form"/>  
                        </p:column>
                         <p:rowExpansion >  
                            <table style="width:100%">
                                    <tbody style="background-color: #5277A9; color: #ffffff; ">
                                     <td >
                                         De
                                     </td>
                                     <td >
                                         Até
                                    </td>
                                     <td style=" text-align: center;">
                                         Cartório
                                     </td>
                                     <td style=" text-align: center;">
                                         Fermojupi
                                    </td>
                                     <td style=" text-align: center;" >
                                         Valor
                                    </td>
                                     <td style=" text-align: center;">
                                         OAB
                                    </td>
                                 </tbody>
                             <ui:repeat value="#{managerEmolumento.findCodAto(ato.codigo)}" var="emol">
                                    <tr>
                                        <td >
                                            <h:outputText value="#{emol.valInicial eq null ? '-': emol.valInicial}" style="float:right;"/>  
                                        </td>
                                         <td >
                                             <h:outputText value="#{emol.valFinal eq null ? '-': emol.valFinal}" style="float:right;"/>  
                                        </td>
                                         <td >
                                             <h:outputText value="R$ #{emol.cartorio eq null ? '-': emol.cartorio}" style="float:right;"/>  
                                        </td>
                                        <td>
                                            <h:outputText value="R$ #{emol.fermojupi eq null ? '-': emol.fermojupi}" style="float:right;"/>  
                                        </td>
                                        <td>
                                            <h:outputText value="R$ #{emol.valor eq null ? '-': emol.valor}" style="float:right;"/>  
                                        </td>
                                        <td>
                                            <h:outputText value="#{emol.oab ? 'SIM' : 'NÃO'}" style="color: #{emol.oab ? 'green':'red'}; font-weight:bold;"/>  
                                        </td>
                                    </tr>
                             </ui:repeat>
                           </table>
                         </p:rowExpansion>
                    </p:dataTable> 

                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
